﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _003文字打怪游戏
{
    /// <summary>
    /// 玩家类-子类
    /// 继承于Character
    /// </summary>
    class Player:Character
    {
        //玩家类独有的字段
        public string WeaponName { get; set; }//武器
        public void SetAttackValue(float atk)
        {
            //protected的字段不能在类的外部直接访问
            //但可以在子类的内部使用
            if(atk < 50)
                AttackValue = atk;
        }
        /// <summary>
        /// 当父类拥有带参数的构造函数时
        /// 子类的构造函数必须调用父类的构造函数对父类空间进行初始化
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="hp"></param>
        /// <param name="defense"></param>
        /// <param name="av"></param>
        public Player(string name, int hp, float defense, float av,string wn) : base(name, hp, defense,av)
        {
            //Console.WriteLine("Player类构造方法被调用");
            WeaponName = wn;
        }

        /// <summary>
        /// 重写父类的输出属性方法
        /// </summary>
        public override void PrintCharacterAttr()
        {
            base.PrintCharacterAttr();//调用父类的方法
            Console.WriteLine("武器:{0}",WeaponName);
            Console.WriteLine("------------------");
        }


    }
}
